$(document).ready(function () {
    //当前页面打开窗口的尺寸
    window.onresize = function () {
        changeFrameHeight();
    }
    changeFrameHeight();
    if (CI_TYPE == 'host') {
        var url = ctx + "/HostPage" + "/" + CI_TYPE + "/" + DI_QU;
        $('#systemViewIframe').attr('src', url);
    } else if (CI_TYPE == 'database') {
        var url = ctx + "/DataBasePage" + "/" + CI_TYPE + "/" + DI_QU;
        $('#systemViewIframe').attr('src', url);
    } else if (CI_TYPE == 'middleware') {
        var url = ctx + "/MiddlewarePage" + "/" + CI_TYPE + "/" + DI_QU;
        $('#systemViewIframe').attr('src', url);
    } else if (CI_TYPE = 'networkdevice') {
        var url = ctx + "/ChangerPage" + "/" + CI_TYPE + "/" + DI_QU;
        $('#systemViewIframe').attr('src', url);
    }

    resourceIpName();
});

function changeFrameHeight() {
    var mainIframeHeight = $(window).height();
    var systemViewIframeHeight = mainIframeHeight - 113;
    $('#systemViewIframe').height(systemViewIframeHeight);
}

///*资源搜索*/弹出列表框
function resourceIpName() {
    $.ajax({
        url: ctx + "/kpiContrast/queryResouceByName",
        async: false,// 异步请求
        type: 'post',
        data: {
            DI_QU: DI_QU,
            CI_TYPE: CI_TYPE
        },
        success: function (data) {
            var list = JSON.parse(data);
            $.each(list, function (index, item) {
                $("select[name='resourceName']").append("<option value='" + item.EXT_UNIT_ID + "'>" + item.RESOURCENAME + "</option>");
            });
            if ($('#resourceName')) {
                $('#resourceName').chosen({search_contains: true});
            }

        }
    });
}

//查询按钮代参跳转页面
$('#searchBtn1').click(function () {
    var select = $('#dataDimensionalitySelect option:selected').val();
    var unit_id = $('#resourceName').val();
    var ccname = unit_id.split(':');
    var classname = ccname[0];
    var kbpCodeSjk = unit_id.substr(0, 6);
    var kbpCodeLinuxServer = unit_id.substr(0, 11);
    var kbpCodeIBMAixServer = unit_id.substr(0, 12);
    var kbpCodeWindows = unit_id.substr(0, 7);
    var kbpCodeZjj = unit_id.substr(0, 8);
    var kbpCodeJhj = unit_id.substr(0, 13);
    if (unit_id == null || unit_id.length == 0 || unit_id == " ") {
        $(this).dynamicPop('请选择资源!', null, null, 'left');
    } else if (select == null || select.length == 0 || select == " ") {
        $(this).dynamicPop('请选择统计维度!', null, null, 'left');
    } else if (kbpCodeLinuxServer == 'LinuxServer') {
        var url = ctx + "/Host/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    } else if (kbpCodeIBMAixServer == 'IBMAixServer') {
        var url = ctx + "/Host/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    } else if (kbpCodeWindows == 'Windows') {
        var url = ctx + "/Host/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    } else if (kbpCodeSjk == 'Oracle') {
        var url = ctx + "/DataBase/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    } else if (kbpCodeZjj == 'Weblogic') {
        var url = ctx + "/MiddleWare/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    } else if (kbpCodeJhj == 'NetworkDevice') {
        var url = ctx + "/changer/" + unit_id + "/" + select + "/" + classname;
        $('#systemViewIframe').attr('src', url);
    }
})





